$(function () {
    window.app.page['docList'] = {
        divDocList: $('#docList'),
        parentId: window.app.util.getUrlParam('parentId'),
        viewModel: function (data) {
            var self = this;
            self.allDoc = $.map(data.data, function (item) {
                item.formatPublishTime = "时间：" + item.docPubtime;
                return item;
            });
            self.total = data.dataTotal;

            self.seeDetail = function (item) {
                if (item) {
                    // open doc detail
                    window.location.href = '/mobile/index.html?page=docDetail&id=' + item.docId;
                }
            };
        }
    };

    window.app.page.docList.fn = {
        init: function () {
            window.app.util.restClient('/thirdPart/nmgat/docList/' + window.app.page.docList.parentId, null, function (data) {
                ko.applyBindings(new window.app.page.docList.viewModel(data), window.app.page.docList.divDocList[0]);
                $.hideLoading();
            })
        }
    };

    window.app.route.docList.successFun = window.app.page.docList.fn.init;
});